package com.mayikt;

/**
 * @Author: maplefire
 * @Description: 实现Runnable接口创建线程
 * @Date: 2022/06/16 17:00
 */

class CreateRunnable implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("子..i:" + i);
        }
    }
}

// 1.实现runnable接口，重写run方法
public class ThreadDemo02 {
    public static void main(String[] args) {
        System.out.println("main...主线程开始...");
        // 创建线程
        CreateRunnable createRunnable = new CreateRunnable();
        Thread t1 = new Thread(createRunnable);
        // 启动线程
        t1.start();
        for (int i = 0; i < 10; i++) {
            System.out.println("main..." + i);
        }
        System.out.println("main...主线程结束...");
    }
}
